package com.soundking.server.controller;

import com.soundking.server.SystemCache;
import com.soundking.server.service.WxWorkService;
import com.xuhe.wx.controller.IWeixinWorkUtilBaseController;
import com.xuhe.wx.dto.WxWorkMsgDTO;
import com.yszn.base.result.ResultVO;
import com.yszn.base.result.ResultVOUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wxWorkUtil")
@Api(tags = {"企业微信工具"})
@Slf4j
public class WeixinWorkUtilController extends IWeixinWorkUtilBaseController {
    @Autowired
    private WxWorkService wxWorkService;

    @Override
    protected String getAccessToken() {
        if (SystemCache.wxWorkAccessToken.get() == null) {
            wxWorkService.refreshAccessToken();
        }
        return SystemCache.wxWorkAccessToken.get();
    }

    @Override
    protected String getAgentId() {
        return SystemCache.wxWorkAgentId;
    }
}
